// 模拟数据
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'API.dart';
import 'dart:convert';
class MockRequest{
  Future<dynamic> get(String action,{Map params}) async {
    return MockRequest.mock(action: getJsonName(action),params: params);
  }
  static Future<dynamic> post({String action, Map params}) async {
  return MockRequest.mock(action: action, params: params);
}
  static Future<dynamic> mock({String action,Map params}) async {
    var responseStr = await rootBundle.loadString('mock/$action.json');
    var responseJson = json.decode(responseStr);
    return responseJson;
  }
  Map<String, String> map = {
      API.IN_THEATERS: 'in_theaters',
      API.COMING_SOON: 'coming_soon',
      API.TOP_250: 'top250',
      API.WEEKLY: 'weekly',
      API.REIVIEWS: 'reviews',
    };

    getJsonName(String action) {
      return map[action];
    }
}
